import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.StringTokenizer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import util.*;

public class SgxSupported {

	private HashMap<String, Candle> candles_2;
	private HashMap<String, Candle> candles_1;
	private HashMap<String, Candle> candles_0;
	private HashMap<String, Triplet<Candle, Candle, Candle>> candleTriplets;

	public SgxSupported(String filename_2, String filename_1, String filename_0) {
		candles_2 = new HashMap<String, Candle>();
		Util.readFile(filename_2, candles_2);
		candles_1 = new HashMap<String, Candle>();
		Util.readFile(filename_1, candles_1);
		candles_0 = new HashMap<String, Candle>();
		Util.readFile(filename_0, candles_0);
		
		candleTriplets = Util.matchCandleTriplets(candles_2, candles_1, candles_0);
		
		Iterator<String> iter = candleTriplets.keySet().iterator();
		while (iter.hasNext()) {
			String stockName = iter.next();
			Triplet<Candle, Candle, Candle> candles = candleTriplets.get(stockName);
			Candle candle_2 = candles.getA();
			Candle candle_1 = candles.getB();
			Candle candle_0 = candles.getC();

			int numTicks = candle_2.isSupported(2, candle_1, candle_0);
			if (numTicks >= 5) {
				String paddedStockName = String.format("%1$-30s", stockName);
			      DecimalFormat formatter = new DecimalFormat("#.#"); 
				System.out.println(paddedStockName + "\t" + formatter.format(numTicks));
			}
		}
	}
	
	public static void main(String[] args) {
		new SgxSupported(args[0], args[1], args[2]);
	}

}
